<template>
  <div class="app">
    <div class="dafaaf">
      <div>
        <img src="@/assets/1.png" alt />
        <div class="aaffafff">
          <div>尝新</div>
          <div>尝热</div>
          <div>尝潮流</div>
        </div>
      </div>
    </div>
    <div class="register-wrapper">
      <div id="register">
        <p class="title">会员登录</p>
        <el-form
          :model="ruleForm2"
          status-icon
          :rules="rules2"
          ref="ruleForm2"
          label-width="0"
          class="demo-ruleForm"
        >
          <el-form-item prop="tel">
            <el-input v-model="ruleForm2.loginPhone" auto-complete="off" placeholder="请输入手机号"></el-input>
          </el-form-item>
          <el-form-item prop="pass">
            <el-input
              type="password"
              v-model="ruleForm2.password"
              auto-complete="off"
              placeholder="输入密码"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm2')" style="width:100%;">登录</el-button>
            <div class="dolon">
              <p class="login" @click="gotoLogin">没有账号？立即注册</p>
              <!-- <p class="login" @click="modify">忘记密码</p> -->
            </div>
          </el-form-item>
        </el-form>
        <div class="coagent" id="kbCoagent">
          <div @click="qqlog">
            <a :href="qqdata">
              <img src="@/assets/img/qq.png" alt /> QQ
            </a>
          </div>

          <div @click="wxlog" class="adqqxw">
            <a :href="lwxlogin">
              <img src="@/assets/img/wx.png" alt />微信
            </a>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Register",
  data() {
    // <!--验证手机号是否合法-->
    let checkTel = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入手机号码"));
      } else if (!this.checkMobile(value)) {
        callback(new Error("手机号码不合法"));
      } else {
        callback();
      }
    };
    // <!--验证密码-->
    let validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.ruleForm2.checkPass !== "") {
          this.$refs.ruleForm2.validateField("checkPass");
        }
        callback();
      }
    };
    return {
      qqdata: "",
      lwxlogin: "",
      ruleForm2: {
        loginPhone: 17671116739,
        password: ""
        // smscode: ""
      },
      rules2: {
        loginPhone: [{ validator: checkTel, trigger: "change" }],
        password: [{ validator: validatePass, trigger: "change" }]
        
      },
      isDisabled: false, // 是否禁止点击发送验证码按钮
      flag: true
    };
  },
  mounted() {
    this.qqlog();
  },
  methods: {
    submitForm() {
      var that=this
      this.$store.dispatch('Login', this.ruleForm2).then(() => {
        console.log(2)
        that.$router.push('/core')
      }).catch(err => {
        console.log(1)
        console.log(err)
      })
    },
    // <!--进入注册页-->
    gotoLogin() {
      this.$router.push({
        path: "/register"
      });
    },
    wxlog() {
      // let _this=this
      // axios.get('http://47.105.66.232:8066/base/login/h5/getWOpenid')
      // .then(function (res) {
      //    _this.lwxlogin = res.data.body;
      //   // console.log(res);
      // })
    },
    // 验证手机号
    checkMobile(str) {
      let re = /^1\d{10}$/;
      if (re.test(str)) {
        return true;
      } else {
        return false;
      }
    },
    qqlog() {
      // let _this = this
      // axios.get('http://47.105.66.232:8066/base/login/h5/getQOpenid')
      // .then(function (res) {
      //   _this.qqdata = res.data.body;
      //   // console.log(res.data.body);
      // })
    }
  }
};
</script>

<style scoped>
.loading-wrapper {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background: #aedff8;
  display: flex;
  align-items: center;
  justify-content: center;
}
.register-wrapper img {
  position: absolute;
  z-index: 1;
}
.register-wrapper {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  bottom: 0;
  background-color: #ec8741;
  background-image: url(../assets/835b09d8d541afe685cef4582043ac2.png);
  background-repeat: no-repeat;
  background-position: center;
  background-position-y: 113px;
  background-position-x: -29px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
}
#register {
  max-width: 340px;
  background: #fff;
  padding: 20px 40px;
  border-radius: 10px;
  position: relative;
  z-index: 9;
  top: -22%;
  right: 230px;
}
.title {
  font-size: 26px;
  line-height: 50px;
  font-weight: bold;
  margin: 10px;
  text-align: center;
}
.el-form-item {
  text-align: center;
}
.login {
  margin-top: 10px;
  font-size: 14px;
  line-height: 22px;
  color: #1ab2ff;
  cursor: pointer;
  text-align: left;
  text-indent: 8px;
  width: 160px;
}
.login:hover {
  color: #2c2fd6;
}
.code >>> .el-form-item__content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.code button {
  margin-left: 20px;
  width: 140px;
  text-align: center;
}
.el-button--primary:focus {
  background: #409eff;
  border-color: #409eff;
  color: #fff;
}
.dolon {
  display: flex;
  justify-content: space-between;
  width: 430px;
}
.coagent {
  width: 180px;
  height: 40px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
.coagent div {
  width: 50px;
}
.coagent div img {
  width: 40px;
  height: 40px;
  margin-left: -41px;
  margin-top: -9px;
}
.dafaaf {
  height: 108px;
  background-color: #fff;
  z-index: 10;
  position: relative;
}
.dafaaf img {
  margin-top: 20px;
  margin-left: 240px;
}
.aaffafff {
  display: flex;
  position: relative;
  top: -85px;
  left: 900px;
}
.aaffafff div {
  font-size: 24px;
  margin-left: 30px;
  line-height: 100px;
  color: #ec8741;
  margin-top: 20px;
}
.adqqxw {
  cursor: pointer;
}
</style>
